<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>袋子里最少数目的球</title>
</head>
<body>
  <script>
    function fn(nums, maxOperations) {
      let left = 1, right = Math.max(nums), ans = 0;
      while (left <= right) {
        const y = Math.floor((left + right) / 2);
        let ops = 0;
        for (const x of nums) {
          ops += Math.floor((x - 1) / y);
        }
        if (ops <= maxOperations) {
          ans = y;
          right = y - 1;
        } else {
          left = y + 1;
        }
      }
      return ans;
    }
    console.log(fn([9], 2))
  </script>
</body>
</html>